home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 3
/
Cream of the Crop 3.iso
/
utility
/
xset402.zip
/
XSET.DOC
< prev
next >
Wrap
Text File
|
1994-03-29
|
53KB
|
1,344 lines
╔═════════════════════════════════════════════╗
║ XSET 4.02 : Extended SET Instruction ║░░
║ ║░░
║ (C) 1991-1994 Stern Marc ║░░
╚═════════════════════════════════════════════╝░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Everything you always wanted to put in an environment variable but
were afraid to ask DOS for . . .
XSET: The easy way to write efficient batch files.
XSET allows you to put EVERYTHING you want in a variable of the
current DOS environment and use it as if you assigned it the value with
the standard DOS command 'SET'. You will be able to write very efficient
batch files including string manipulation, calculation, ...
XSET is the most powerful environment variables manipulation program
you ever saw. It also has a very easy and intuitive user interface (very
close to the DOS 'SET' command). It is not a resident program; it so
cannot interfere with any of your other applications.
XSET is fully compatible with MS-DOS (from 3.30), DR-DOS, NDOS & 4DOS.
XSET has seven major features:
═════════════════════════════
- XSET permits to catch the output of any command (internal or
external) or program and put it into an environment variable.
- XSET has built-in commands to modify the output of a program or a
string given on the command-line (extract a part of a string, ...)
- XSET has a built-in full floating-point calculation functionality:
You can program incremental loops, input a calculation string and
output the resulting number, ...
- XSET can manage variable contents of more than 128 characters (your
path can now be as long as you want).
- XSET has other built-in commands to give you access to some system
data (date, time, ...)
- XSET has built-in commands to clear all environment or restore a
previously saved one.
- XSET gives you access to high-level user interface input/output
(line-editing, colors, windows, boxes, ...).
More than sixty commands to do all what you need.
Page 1
╔═════════════════════════════╗
║ Table of contents ║░░
╚═════════════════════════════╝░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
The Shareware concept .................................... Page 2
How to use XSET .......................................... Page 3
Examples of use .......................................... Page 4
Syntax explanation ....................................... Page 7
Input explanation ........................................ Page 7
Options and commands description ......................... Page 8
Input related flags .................................... Page 8
Prompt related flags ................................... Page 9
String related flags ................................... Page 10
Other flags ............................................ Page 11
Order of execution of /options ......................... Page 13
Input commands ......................................... Page 14
Date & time commands ................................... Page 15
Disk & file commands ................................... Page 16
Other commands ......................................... Page 19
Special flags .......................................... Page 20
XSET & XSET_MSG variables ................................ Page 21
Installation ............................................. Page 22
Problems ................................................. Page 22
Batch file programming: Hints & tips ..................... Page 24
Additional information - How to contact the author ....... Page 25
Appendix: E-mail address from other sites ................ Page 25
Page 2
╔═════════════════════════════╗
║ The Shareware concept ║░░
╚═════════════════════════════╝░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
This package is Shareware.
That means that you may try it for evaluation and, if you like it, you
should consider to pay the registration fee (see the file
'REGISTER.HOW'). You will then become a registered user and so have
access to free support, free correction of acknowledged bugs and free
upgrades.
Shareware also mean that you may distribute this package everywhere and
to everybody you want, providing that you always distribute the complete
package. If you have access to any BBS, FTP server, E-mail server or any
other kind of software distribution, feel free to share it with other
people; this may be useful for them and the more people will use (and
register) a shareware program, the more stable it will be and the more
functionalities could be added.
Warning: If you paid to get this package (e.g., it was onto a floppy
─────── with other programs, you downloaded it from a BBS), you only
paid for the physical support (the floppy, the transmission
fee, ...); this does not replace the registration fee.
Note to software distributors:
─────────────────────────────
Nobody is allowed to make any benefit by distributing the XSET
package. Only regular distribution fees are allowed (price of the
floppy, of the network connection, ...).
Page 3
How to use XSET:
═══════════════
XSET will always assign what you tell it into a DOS environment
variable. The main goals of XSET are:
- to ask a question to the user (through the keyboard),
- to catch the output of a program or a command,
- to get pieces of information like current date and time, timestamp
or size of a file, ...
- to modify a string (contained in another variable, in a parameter,
...) like changing it to lower-/upper-case, performing a search on
it, calculating the result of a mathematical expression,
substituting a sub-string by another or extracting a part of it,
- to handle variables longer than 128 characters.
There are four ways to use XSET.
1. Like the normal DOS 'SET' command:
XSET myvar="This is a test string"
2. To get an input from the user:
XSET answer
3. To catch the output of a program or a command:
dir c:\programs\myprog.c | XSET myvar
4. To get various system or environment information:
XSET myvar TIME
Furthermore, to attain a high level of functionality you may add, to
each of the above syntaxs, several option flags to modify the default
behavior of XSET (for example /UPPER to translate into upper-cases, ...).
Syntax: XSET [/OPTIONS...] <dosvar>
────── read a string from standard input
XSET [/OPTIONS...] <dosvar>="string"
equivalent to the DOS command 'SET'
XSET [/OPTIONS...] <dosvar> COMMAND [arguments ...]
╔══════════════════════════════════════════════════════╗
║ Type XSET /? to get the full description ║░░
║ of all functionalities (parameters and effects). ║░░
╚══════════════════════════════════════════════════════╝░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Remark: Intensive use of XSET (and more generally of DOS environment
variables) may require that you expand the size of your DOS
environment space through the SHELL command. See the PROBLEMS
section for more details.
Page 4
Examples of use:
═══════════════
Remark: In all the examples, the command XSET and its built-in
commands are typed in upper-case and the environment variables
names are in lower-case. This is only for readability; when
you type it, you may mix lower-cases and upper-cases as you
like. The case is only significant for arguments strings you
enter on the command-line.
1) XSET datvar DATE
Assigns the current system date into the variable 'datvar'
Type the DOS command 'SET' to see all the environment variables;
you will get something like this:
...
COMSPEC=...
DATVAR=dd-mm-yy (where dd,mm,yy are replaced by current day,
month and year)
... (other variables)
You can now use the variable 'datvar' in a batch file:
ECHO the date is %datvar%
2) XSET /COLOR LIGHTRED /PROMPT "Enter your name: " name
Inputs a string from the keyboard (as usual, the answer is
terminated by <Enter>) and assigns it into the variable 'name'. The
prompt appears in the specified color (or the equivalent attribute
on monochrome displays).
You can now use the variable 'name' in a batch file to select a
personalized environment for each user:
ECHO Hello %name%, have a good work session
CD \%name%
3) You can write a batch file with automatic loops
rem ------------------
set loop=1
:next
.......
anything you want
.......
XSET /MATH loop=%loop% + 1
if not %loop% == 20 goto next
rem ------------------
Page 5
4) You can write a batch file where the user may enter
a calculation and use it as a number
rem ------------------
XSET /MATH /PROMPT "Enter your calculation: " calc
echo result = %calc%
rem ------------------
5) More elaborate example of a login procedure
rem ---------------------- LOGIN.BAT --------------------------------
@echo off
cls
:BEGIN
rem Ask login name from keyboard
rem ----------------------------
XSET /PROMPT "Enter login name : " login
rem Test if directory corresponding to login name already exist
rem -----------------------------------------------------------
if exist c:\%login%\nul goto OK
rem Directory does not exist, ask to create it
rem ------------------------------------------
echo:
echo Login '%login%' does not exist.
rem Only "yYnN" keys are allowed
rem ----------------------------
XSET /PROMPT "Do you want to create it? (Y/N)" /UPPER ask KEY "YN"
if %ask% == N goto BEGIN
rem Create directory
rem ----------------
md c:\%login%
:OK
set ask=
rem Go to user's directory and branch to personal
rem batch file if any.
rem ---------------------------------------------
cd \%login%
if exist autouser.bat autouser.bat
rem -----------------------------------------------------------------
Page 6
6) You are able to use a single password input for several
network connections
rem -----------------------------------------------------------------
echo off
cls
rem Ask login name from keyboard
rem ----------------------------
XSET /PROMPT "Enter login name : " login
rem Ask password from keyboard
rem --------------------------
XSET /PROMPT "Enter password : " passwd PASSWD
rem Connection to several network nodes
rem -----------------------------------
net use node1 ... %login% %passwd%
net use node2 ... %login% %passwd%
net use node3 ... %login% %passwd%
rem Overwrite variable containing password (to be sure)
rem --------------------------------------
set passwd=something_longer_that_password_to_be_sure
rem Clear variable containing password (to free environment)
rem ----------------------------------
set passwd=
rem -----------------------------------------------------------------
7) And much more ...
See also DEMO.BAT and ENVEDIT.BAT
Page 7
Syntax explanation:
══════════════════
[...] are optional arguments;
if they are not specified, a default one is assumed.
{...} are mandatory arguments;
if they are missing from the command-line, they are read from the
standard input device (usually the keyboard or, if using redirection, a
file or the output of another command).
Strings arguments have to be included in double quotes (") if they
contain any special characters like characters interpreted by
COMMAND.COM. See remark in section 'Problems'. This implies that all
double quotes will be removed from the strings arguments. Strings
arguments to option flags also have to be quoted ("") if they contain
spaces or tabs.
Input editing:
═════════════
When you input a string from the keyboard, you may use several edition
facilities:
When a default string is proposed:
- if any editing character (Home, <-, ->, ...) is hit you may edit the
proposed string,
- otherwise, default string is erased and replaced by the new input you
type in; this feature is only active for the first key you hit.
Valid keys: Home Begin of line
End End of line
Left/Right One character left/right
Insert Toggle insert on/off
Delete Delete current character
BackSpace Delete previous character
Ctrl-home Erase to begin-of-line
Ctrl-end Erase to end-of-line
Escape Erase whole input
Enter Accept input
If a timeout is specified (see /TIMEOUT flag) the function may
automatically return if no key is hit before the specified time.
Page 8
Options and commands description:
════════════════════════════════
Remarks: - In the following descriptions, the word 'function' stands for
both 'option flag' and command. This only means any
functionality of XSET.
- The word 'result' in the option flags description stands for
the current contents of the variable at the moment the
considered flag is processed (i.e., after the already
executed functions).
Input related flags:
───────────────────
These are modifiers that can be used with all functions.
/DEFAULT
set current value of variable as default for input.
ex: set name=SMITH
XSET/DEFAULT/PROMPT "Enter your name:" name
/TIMEOUT n
breaks the input if no key was hit after n seconds; once any key has
been hit, you may edit your line during any time you need. If you didn't
hit any key before n seconds, the input is cancelled and the resulting
DOS environment variable is set to empty (i.e., deleted) or to its
previous value if the /DEFAULT flag was used.
- if the time-out delay has been reached, the program will set the DOS
environment variable XSET_MSG to TIME-OUT (to let you check for it),
- if n = 0, the program will check for type-ahead (i.e., XSET will enter
into edit mode only if a key was hit at the moment of the check),
- if n < 0, time-out will be active during the whole input process; if
you wait more than abs(n) seconds between two keys, the program will
return the string typed so far.
- this option is only active if standard input is not redirected,
- this option is also active with the KEY command (see further).
/LINE n
This reads the <n>th line from the standard input device
(instead of the first one).
-1 will read the last line,
-2 will read the line before, ...
ex: dir *.exe | XSET /LINE -2 /word 3 filenb
This will get the number of files matching *.exe and assign it to
DOS environment variable 'filenb':
- read the line before the last one from the output of the 'dir'
command (something like ' 15 file(s) 87912 bytes').
- pick up the third word on this line.
Page 9
Prompt related flags:
────────────────────
These are modifiers that can be used with all functions.
/PROMPT string
Display a message on the screen.
/COLOR color
Set color for prompt (and border if any).
Valid colors: BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN DARKGRAY,
LIGHTGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED,
LIGHTMAGENTA, YELLOW, WHITE
Remark: If a monochrome video card is detected, the /COLOR and
/BACKGROUND options will be ignored; if you have a color video
card and a monochrome display screen, the colors will be mapped
by the screen itself as with any other program.
/BACKGROUND color
Set background color for prompt (and window if any).
Valid colors: BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, DARKGRAY,
LIGHTGRAY
/BLINK
To choose a blinking prompt (may be used with /COLOR).
/XPOS x
Set cursor to column x (or current - x if x < 0) before displaying prompt.
/YPOS y
Set cursor to line y (or current - y if y < 0) before displaying prompt.
/WINDOW left top right bottom
Draw a window (using color specified with /BACKGROUND).
ex: XSET/BACKGROUND RED /WINDOW 3 2 12 8
Draw a red window from position (column 3, line 2) to position
(column 12, line 8).
/BOX
Draw a window (using color specified with /BACKGROUND) around the prompt
(specified with /PROMPT); your answer (if any) will be outside the box.
ex: XSET/BACKGROUND RED /BOX /PROMPT "Hello, enter your name:"
Draw a red window with the prompt inside.
/BORDER
Add a border inside a window (specified with /WINDOW or /BOX). Rem: When
using /BORDER, /BOX is assumed by default. If you wish to use /BORDER
around a user-defined window, both /BORDER and /WINDOW are required.
ex: XSET/BACKGROUND RED /BOX /BORDER /PROMPT "Hello, enter your name:"
XSET/BACKGROUND RED /BORDER /PROMPT "Hello, enter your name:"
The two examples above are equivalent.
XSET/BACKGROUND RED /BORDER /WINDOW 3 2 12 8
page 10
String related flags:
────────────────────
These modifiers can be used with all functions and modify their result.
/UPPER - /LOWER
This translates the result into upper/lower-cases.
Characters like éèàâÅ... are also translated to EA... (or ea...).
- This also affects the arguments given to the KEY command,
- This also affects the first argument given to the /SEARCH, /INDEX and
/CHANGE option flags except if the /REGEXP flag is specified.
/LEFT n, /RIGHT n
This picks the leftmost / rightmost <n> characters of the result (or
less if result is shorter than <n>).
ex: XSET/LEFT 2 drive=%full_pathname%
/MID m n
This picks the <n> characters starting from the <m>th one of the result
(or less if result is shorter than <m> + <n>).
First character has index 1.
ex: XSET/MID 2 5 var=%other%
Assigns characters 2, 3, 4, 5 & 6 from %other% to 'var'.
/WORD n
This picks the <n>th word (separated from other ones by any number of
blanks) of the result.
Other separators may be specified with the /SEPARATOR flag.
If no word is found, an empty string is returned.
/SEPARATOR string
This uses the characters from 'string' as word separator.
This option is intended to be used with /WORD and /COUNT.
ex: XSET/SEPARATOR "+-*/()" /WORD 3 var="25+6*(-72+3)"
Assigns the string 72 to 'var' (25 is first word, 6 is second, ...).
/LENGTH
This returns the length of the result.
/COUNT
This returns the number of words (separated from other ones by any
number of blanks) in the result.
Other words separators may be specified with the /SEPARATOR flag.
Page 11
/SEARCH string
This returns the portion of the result matching <string>.
See also /REGEXP.
ex: XSET/PROMPT "Enter your name: "/UPPER/SEARCH "SMITH" var
If the answer contains 'SMITH' (even in lower-cases), variable 'var'
will be assigned to 'SMITH'; otherwise, variable 'var' will be
empty.
XSET/REGEXP/SEARCH "[0-9]+" var=%answer%
Variable 'var' will be assigned to the first occurrence of a string
containing only digits (like 2056) from the variable 'answer'.
/INDEX string
This returns the index (position) of the portion of the result
matching <string>.
First character has index 1.
See also /REGEXP.
/CHANGE string1 string2
This changes (substitutes) all occurrences of <string1> by <string2> in
the result.
ex: XSET/CHANGE "oldstr" "newstring" var=%answer%
Other flags:
───────────
/APPEND
This adds the result to the existing variable instead of overwriting it.
This allows you to bypass the 128 characters limit of DOS (see /VIEW)
ex: XSET/APPEND path=";c:\msc600\bin;c:\msc600\binb"
/MATH
This performs a mathematical calculation on the string.
Mathematical operators:
- on integer and floating point values: + - * / () ^ (exponent)
- on integer values: % (modulo)
Logical operators: = < > <= >= <>
return 1 if true, 0 if false
Rem: '*' may be used to 'and' values,
'+' to 'or' them.
Precedence: + and - have the highest precedence,
all other expressions are evaluated from left to right.
ex: XSET /MATH var = "3+(2*5) + %new% + (%loop% <= 5)"
XSET /MATH /PROMPT "Enter your calculation" result
Page 12
/REGEXP
This performs UNIX-like regular expression matching with the arguments
given to the /SEARCH, /INDEX and /CHANGE option flags.
A UNIX-like regular expression is one or more occurrences of one or more
characters.
The following symbols have a special meaning:
^ start of line (see also below: 'inside set of characters')
$ end of line
. any character
\ quote next character (i.e., do not treat it as a special character)
* match zero or more time preceding character (or character set)
+ match one or more time preceding character (or character set)
? match one or zero time preceding character (or character set)
[] set of characters
inside set of characters: ^ means non-inclusion
- means range
ex: [aeiou0-9] match a, e, i, o, u, and 0 through 9
[^ae0-9] match anything but a, e and 0 through 9
^a match any line beginning by 'a'
v$ match any line ending by 'v'
ex: XSET /REGEXP /SEARCH "[a-zA-Z]:[a-zA-Z0-9_\\.]+" myvar
will search for a standard DOS filename (from standard input)
[a-zA-Z] match any characters included in the range
'a' to 'z' and 'A' to 'Z'.
: match the character ':'
[a-zA-Z0-9_\\.] match any characters included in the range
'a' to 'z', 'A' to 'Z', '0' to '9' and the
characters '_', '\' and '.'.
\\ match the character following the first '\',
is this case a second '\'.
+ match one or several characters (the preceding
one, which is here a set of characters).
This instruction matches any filename of the form 'drive:pathname'
(ex: C:\DIR\OTHERDIR\FILE.EXT).
/ALL This modifies all DOS environments in memory; i.e., not only
the current shell (COMMAND.COM) environment but also the
previous ones (if any). ex: XSET /ALL /APPEND path=";c:\bin"
Warning: If one of the environments is not big enough to contain the
new variable, no error message is displayed.
page 13
Order of execution of /options:
──────────────────────────────
/PROMPT + related (/COLOR, /BACKGROUND, /BLINK, /XPOS, /YPOS,
/WINDOW, /BORDER, /BOX)
input (/DEFAULT, /TIMEOUT, /LINE)
/UPPER, /LOWER
/WORD
/LEFT
/RIGHT
/MID
/REGEXP
/SEARCH
/INDEX
/CHANGE
/LENGTH
/COUNT
/MATH
/APPEND
/ALL
/VIEW
page 14
Input commands:
──────────────
KEY [string]
This waits for a key pressed and assign the result to the DOS
environment variable. If a string argument is added to the command, only
the characters appearing in the string are allowed; if another key is
hit, you will hear a beep. Printable characters (ASCII code from 32 to
255) return the character corresponding to the key (ex: A returns 'A').
Non-printable characters (ASCII code lower than 32) return their decimal
ASCII code preceded by a '#' (ex: Ctrl-A returns '#1'). Extended keys
(arrows, function keys, Home/end, PageUp/PageDown, ...) return their
decimal scan code added to 256 preceded by a '#' (ex: F1 returns
'#315'). See your technical documentation for a list of your keyboard
scan codes. If you used the /TIMEOUT flag, the program will return after
the specified time if no valid key was hit. The resulting variable will
be empty.
ex: XSET k KEY 123aAbB only keys '123aAbB' are allowed
ex: XSET k KEY all keys are allowed
ex: XSET/UPPER k KEY abc only keys 'aAbBcC' are allowed
PASSWD
This reads characters from keyboard without echo on screen.
It is intended to input a password or a secret information.
page 15
Date & time commands:
────────────────────
DATE
This returns the system date in the format 'dd-mm-yy' (ex: 31-12-93).
YYMMDD
This returns the system's date in the format 'yymmdd' (ex: 931231).
This format is very useful to generate filenames from the current date.
DAY
This returns the system's day of the month (1-31)
MONTH
This returns the system's month number (1-12)
YEAR
This returns the system's system year (4 digits - ex: 1993)
DAYOFWEEK
This returns the system's day in the week (0 = sunday, 1 = monday, ... )
TIME
This returns the system's time in 24h format 'hh:mm:ss' (ex: 22:15:06)
HOUR
This returns the system's hour (0-24).
MINUTE
This returns the system's minutes (0-59).
SECOND
This returns the system's seconds (0-59).
DIFFDATE date1 date2
This returns the number of days between <date1> and <date2>. <date1> and
<date2> may be of both format from 'dd-mm-yy' or 'yymmdd' (you may even
mix them). If <date2> is before <date1>, the result will be negative.
Rem: if yy is lesser than 100, 1900 is added (1994 is the same as 94).
page 16
Disk & file commands:
────────────────────
Remarks: - The filenames given as arguments to these commands may be any
valid or invalid filenames. They may be an absolute pathname
or a relative one. They will never be checked for existence,
only their name will be resolved (canonized) following the
normal DOS conventions.
- The drive given as arguments to these commands must be a
letter from 'a' to 'z' (or 'A' to Z') optionally followed by
a period ':'.
FPATH {file} This returns the full pathname of a filename.
ex: XSET myvar FPATH ..\myprog.exe
will put in myvar something like 'C:\PROGRAMS\MYPROG.EXE'
FDRIVE {file}
This returns the drive of a filename.
ex: XSET myvar FDRIVE myprog.exe
will put in myvar 'C:'
FDIR {file}
This returns the drive & directory of a filename.
ex: XSET myvar FDIR c:myprog.exe
will put in myvar 'C:\PROGRAMS\EXE\'
FEXT {file}
This returns the extension of a file name (no period included).
ex: XSET myvar FEXT c:\exe\myprog.exe
will put in myvar 'EXE'
FNAME {file}
This returns the name of a file without extension.
ex: XSET myvar FNAME c:\exe\myprog.exe
will put in myvar 'MYPROG'
FXNAME {file}
This returns the name & extension of a file.
ex: XSET myvar FXNAME h:myprog.exe
will put in myvar 'MYPROG.EXE'
page 17
TRUENAME {file}
This returns the full truename of a file, solving all SUBST, ASSIGN and
JOIN commands and some network names (for those networks compatible with
MS_LAN redirector).
ex: XSET myvar TRUENAME myprog.exe
will put in myvar something like 'C:\PROGRAMS\EXE\MYPROG.EXE'
XSET myvar TRUENAME h:myprog.dat (where h: is SUBSTed to C:\DATA)
will put in myvar something like 'C:\DATA\MYPROG.DAT'
XSET myvar TRUENAME h:myprog.dat (where h: is a network drive)
will put in myvar something like '\\SERVER1\SMITH%SMITH\MYPROG.DAT'
FSIZE {file}
This returns the size of a file (in bytes).
FDATE {file}
This returns the modification date of a file (dd-mm-yy).
FTIME {file}
This returns the modification time of a file (hh:mm:ss).
DIR [drive]
This returns the current directory of the specified drive. If no drive
is specified, the current one is assumed.
VOLLABEL [drive]
This returns the volume label of the specified drive. If no drive is
specified, the current one is assumed.
BYTEFREE [drive]
This returns the number of bytes free on the specified drive. If no
drive is specified, the current one is assumed.
page 18
DENSITY [drive]
This returns the drive density (in KBytes - 360, 720, 1200, 1440, 2880)
of the specified floppy drive. If no drive is specified, the current one
is assumed. This command returns the density of the drive, not of the
floppy that currently is in it (there is even no need that a floppy be
present in the drive). The program returns '0' if the drive has an
unknown density or it is not a floppy drive.
DRIVETEST [drive]
This returns the status of the specified drive. If no drive is
specified, the current one is assumed. The result is a concatenation of
one or more string(s) from 'READABLE', 'WRITEABLE', 'NOFORMAT',
'NOTINSERTED', 'INVALID', 'REMOVABLE', 'REMOTE', 'SUBST', 'RAM separated
by '-'.
ex: XSET test DRIVETEST a:
This assigns to the variable 'test' a string like:
'READABLE - WRITEABLE - REMOVABLE' (floppy not protected)
or 'READABLE - REMOVABLE' (floppy protected)
or 'NOTINSERTED - REMOVABLE' (floppy not inserted)
or 'NOFORMAT - REMOVABLE' (floppy not formatted)
So, to test if you have write-access to a drive:
XSET/SEARCH "WRITEABLE" test DRIVETEST a:
Variable 'test' will contain 'WRITEABLE' or will be empty.
page 19
Other commands:
──────────────
MIN ┌{str1...strn}
MAX └{num1...numn}
This returns the minimum/maximum value of numbers or strings list. If
not all arguments are numbers, a string comparison (i.e., a comparison
of ASCII codes of their characters) will be performed.
Rem: A string may not contain <space> or <tab>.
ex: XSET var MIN 3.6 -4 9.02 %num% 'var' will contains '-4'
(providing than %num% >= -4)
XSET var MAX 3.6 $5 abc 3.9j 'var' will contains '$5'
CPU
This returns the processor type: 86, 186, 286, 386 or 486. The value 86
is returned for both the 8086 and 8088 (standard XT) processor. There is
no difference between DX and SX processors. Any non supported processor
compatible with a 486 should be reported as 486.
RANDOM n1 n2
This function returns a random integer number between n1 and n2
(included). This may be useful to choose a random message from a
collection, ...
ERRORLEVEL
This returns the errorlevel code of the last command issued.
This function is only valid for
- MS-DOS COMMAND.COM 3.20, 3.21, 3.30, 4.0, 4.01, 5.0, 6.0,
- NDOS 6.0,
- 4DOS 4.02
If version is not supported, this returns -1
VARCOPY variable
This is strictly equivalent to 'set dosvar=%variable%' but allows to
copy variables longer than 128 characters.
ex: XSET var2 VARCOPY var1
page 20
Special flags:
─────────────
Note: The correct syntax for XSET always needs a DOS environment
variable name except for the flags described below. There is one
other exception; in order to allow you to use the prompting
facilities of XSET without actually using the environment
assignment you may use
XSET [/options] /PROMPT "..."
instead of assigning a dummy variable like
XSET [/options] /PROMPT "..." dummy=
In this case, XSET is only used as an enhanced display program.
XSET /CLEAR deletes all variables from the current DOS environment.
XSET /VIEW shows all variables from the current DOS environment.
This is strictly equivalent to 'SET' but will show
variables longer than 128 characters.
Rem: If you use XSET to assign values longer than 128 characters to a
variable, they will appear truncated when displayed by the DOS
command 'SET'. This is only a display problem of the command
'SET'; all the variables are correctly stored and can be used
without problems by any program.
XSET /VIEW var displays the value of variable 'var'.
This is intended to be used to pass a variable's
content to the standard input of another program. This
is equivalent to 'ECHO %var%|..." except that it can
handle variables longer than 128 characters and you can
use option flags with it.
ex: XSET/LEFT 7 /VIEW myvar | LABEL a: feed the program 'LABEL' with
the first 7 characters of
environment 'myvar'.
XSET /VIEW > SAVEFILE.VAR save all environment variables
into the file SAVEFILE.VAR.
XSET /LOAD loads variables from standard input.
Variables must have been saved with command 'XSET /VIEW'.
ex: XSET /LOAD < SAVEFILE.VAR load all environment variables
from the file SAVEFILE.VAR.
XSET /SIZE displays environment size and free size (in bytes).
page 21
XSET variable:
═════════════
Because you sometimes want to use the same flags for a group of XSET
commands (like /UPPER, /DEFAULT, ...), it would be nice to have a way
to give default options to XSET. And there is such a functionality: the
XSET environment variable.
Before scanning the command line, the XSET program will look for the
'XSET' variable into the current DOS environment. If it exists, the
XSET program will use the variable contents like option flags you would
have given onto the command line. After that, it will use the option
flags given onto the command line. Note that the command line options
may overwrite those contained in the 'XSET' variable.
ex: set XSET=/UPPER/DEFAULT/XPOS 5 /BLINK
XSET /YPOS 12 /PROMPT "First name: " name1
XSET /PROMPT "Last name: " name2
This is also a way to reduce the length of your command line (remember
that COMMAND.COM truncates all lines longer than 128 characters). Note
that you may use XSET/APPEND to assign a very long line to the 'XSET'
variable.
XSET_MSG variable:
═════════════════
This variable is intended to be assigned by the XSET program itself to
a message to specify special events (like a time-out on input, ...).
This variable is updated (or deleted from the environment) each time
the program is called. See the related options and commands to get a
description of the variable contents.
- options and commands using the XSET_MSG variable:
/TIMEOUT
page 22
Installation:
════════════
- XSET.EXE is ready to use; no installation. Just copy XSET.EXE and
XSET.DOC in a directory of your hard drive (usually a directory
included in your path). If you want to use the demo included in
this package (DEMO.BAT), it must be copied in the same directory
as the XSET program. Remember this is a SHAREWARE version intended
to be used for evaluation.
- To get a registered version of XSET, print the XSET.REG file, fill
it in and send it to indicated address; you will then receive the
password required to register your version with the program
REGISTER included in the package.
All further upgrades will be free !!!
Problems:
════════
- If the size of your environment space is not large enough, you
will receive an error message
'XSET : not enough environment space.'
This is not a bug, it is because the environment space reserved
for the variables is too small. You must increase it by modifying
the line 'SHELL=...' in your CONFIG.SYS. By default, DOS reserves
256 bytes environment space; this is generally insufficient. Try
640 bytes (or more if you need it) by adding '/e:640' at the line
'SHELL=...'
ex: SHELL=COMMAND.COM /E:640 /P
If this problem is encountered in a secondary shell (i.e., you run
the batch file from a menu that runs a secondary shell) here is a
way to work around the problem (this is a DOS problem that could
be avoided by the program that runs the secondary shell):
put in your AUTOEXEC.BAT a line such as:
SET TO_DELETE=something_very_long_to_be_sure_this_takes_a_lot_of_space
and, before using variables in the secondary shell delete this
---------
variable with the command:
SET TO_DELETE=
An other way to work around this limitation is to patch
COMMAND.COM; see file 'PATCH.DOS' for more explanation.
page 23
- If you use special characters like <>| you will have a problem
because COMMAND.COM interprets these characters like redirection
commands before giving the control to the program you call. This
is a general DOS problem, but it is very easy to work around.
ex: XSET /MATH var=(%loop% + 3) > 2 (suppose loop=1)
Although you think you call XSET to check if 4 is greater
than 2, COMMAND.COM interprets it as
"put into a file named 2 the result of 'XSET /MATH var (1+3)'"
You will have the same result with '<' and '|'.
The best way to ensure that all special characters you use will be
given 'as is' to the program you call (XSET or another one) is to
enclose your strings between double quotes:
XSET /MATH var="(%loop% + 3) > 2"
Be careful not to quote XSET reserved words (commands or flags)
and variable names.
So do not write
XSET var "MIN abc <def> gh"
or XSET "var MIN abc <def> gh"
but XSET var MIN "abc <def> gh"
- If you want to use the character '%' in a batch file, remember
that this character is reserved for DOS environment variable; so,
if you want to use a 'real' % character, you have to write '%%' in
your batch file.
ex: XSET /MATH var="%other_var% %% 7"
This line in a batch file will put into variable 'var' the
result of '(contents of variable other_var) modulo 7'.
Notice that the use of double quotes doesn't affect the way that
COMMAND.COM interprets the % character; you must double the %
character even if it is quoted.
page 24
Batch file programming: Hints & tips
════════════════════════════════════
1. Whenever it is possible, use 'SET var=...' instead of 'XSET var=...'
because SET is an internal COMMAND.COM's command and is quicker than
calling an external program.
ex: To clear a variable, use SET myvar=
instead of XSET myvar=
If you are sure that the variable 'var1' is shorter than
± 100 characters, use SET var2=%var1%
instead of XSET var2 VARCOPY var1
2. COMMAND.COM reads and execute batch files one line at a time; that
means that it reads one line, execute it and rereads the file from
the beginning to the next line. If you do not have a good disk-cache
installed, it is not efficient. Furthermore, when using 'REM' in
your batch files to insert a remark, COMMAND.COM reads the comment
line, execute it (i.e., does nothing) and rereads the file from the
beginning to the next line. To avoid this, there is a trick: use
'::' instead of 'REM'. ':' is understood as a label to be used by
the 'GOTO' statement (see your DOS documentation); this line will
never be executed. As a label cannot begin with a ':', this line
will not be considered as an executable line, nor as a label.
ex: replace REM This batch file is intended to ...
by :: This batch file is intended to ...
3. To echo an empty line on the screen, use 'ECHO:'
4. To test for the existence of a directory, test for the existence of
the file 'nul.ext' in it (the filename 'nul' should be sufficient
except on a Novell network).
ex: if exist c:\mydir\nul.ext echo The directory 'MYDIR' exists.
5. If an environment variable contains a directory name ending with a
'\', COMMAND.COM will not accept to chdir to this directory.
ex: set dir=c:\mydir\
cd %mydir% ==> Error message: Invalid directory
The trick (to avoid removing the trailing '\') is to add a '.'
ex: cd %mydir%. (note the trailing '.')
See also DEMO.BAT in this package for other tricks.
page 25
Additional information:
══════════════════════
Feel free to contact me for any problem or question. If you have an
electronic mail connection, this is the quickest, cheapest and easiest
way (this would allow me to test your batch files in case of problems
or bug).
Marc Stern
Av. de la Basilique 376 bte 19
1080 Bruxelles
Belgium
Tel: +32-2 525.63.32 ( 9h - 16h Central European Time )
+32-2 427.98.52 ( after 18h Central European Time )
E-mail: stern@mble.philips.be (internet)
>INTERNET:stern@mble.philips.be (compuserve)
see appendix for other networks
APPENDIX: E-mail address from other sites
════════
Rem: This list is obviously not complete and is given here only as
brute information. It also may contain obsolete information, so
do not be surprised if gateway described here-below does not
exist anymore when you try to contact me. If you are connected to
another network or cannot reach Internet with the following
procedure, ask your network manager.
internet : stern@mble.philips.be
aol : stern@mble.philips.be
applelink : stern@mble.philips.be@internet#
att : internet!mble.philips.be!stern
bitnet : stern@mble.philips.be
calvacom : EM/stern@mble.philips.be
compuserve : >INTERNET:stern@mble.philips.be
connect : DASN (first line = "stern@mble.philips.be"@DASN)
easynet : stern@mble.philips.be (from Ultrix)
easynet : stern%mble.philips.be@decwrl.dec.com (from Ultrix via IP)
easynet : DECWRL::"stern@mble.philips.be" (from Ultrix via Decnet)
easynet : nm%DECWRL::"stern@mble.philips.be" (from VMS - NMAIL)
easynet : stern@mble.philips.be @Internet (from VMS - All-in-1)
envoy : [RFC-822="stern(a)mble.philips.be"]INTERNET/TELEMAIL/US
page 26
fidonet : stern@mble.philips.be ON 1:1/31
or send to UUCP gateway with
first line = "To: stern@mble.philips.be"
genie : stern@mble.philips.be@INET#
geonet : DASN (subject line = "stern@mble.philips.be!subject")
gold : /DD.RFC-822=stern(a)mble.philips.be/O=uknet/PRMD=uk.ac/ADMD=gold 400/C=GB/
gsfcmail : (SITE:SMTPMAIL,ID:<stern(a)mble.philips.be>)
or (C:USA,A:TELEMAIL,P:SMTPMAIL,ID:<stern(a)mble.philips.be>)
or POSTMAN (first line = "To: stern@mble.philips.be")
keylink : (C:au, A:telememo, P:oz.au, "RFC-822":
(continuing...) "Marc Stern <stern(a)mble.philips.be>")
mausnet : stern@mble.philips.be
mci : To: Marc Stern (EMS)
EMS: INTERNET
Mbx: stern@mble.philips.be
nasamail : (site:smtpmail,id:<stern(a)mble.philips.be>)
nsi : east::"stern@mble.philips.be"
or dftnic::"stern@mble.philips.be"
or nssdca::in%"stern@mble.philips.be"
or jpllsi::"stern@mble.philips.be"
omnet : type 'compose manual' at the command prompt,
choose 'Internet address' option from the menu,
type 'stern@mble.philips.be'
sinet : M_MAILNOW::M_INTERNET::"stern@mble.philips.be"
or M_MAILNOW::M_INTERNET::mble.philips.be::stern
span : AMES::"stern@mble.philips.be
or HAMLET::"stern@mble.philips.be
or IO::"stern@mble.philips.be
or IUE::"stern@mble.philips.be
or JPLLSI::"stern@mble.philips.be
or NSFGW::"stern@mble.philips.be
or NSSDCA::"stern@mble.philips.be
or STAR::"stern@mble.philips.be
sprintmail : (C:USA,A:TELEMAIL,P:INTERNET,"RFC-822":
(continuing...) <stern(a)mble.philips.be>) DEL
thenet : UTADNX::WINS%" stern@mble.philips.be "
telemail : [INTERMAIL/USCISI]TELEMAIL/USA
with first line = Forward: ARPA
and second line = To: stern@mble.philips.be
wwivnet : stern#mble.philips.be@506